package com.tanhua.server.controller;

import cn.hutool.core.util.ObjectUtil;
import com.tanhua.server.service.HuanXinService;
import com.tanhua.server.vo.HuanXinUserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("huanxin")
@Slf4j
public class HuanXinController {

    @Autowired
    private HuanXinService huanXinService;

    /**
     * 查询环信用户信息
     * @return
     */
    @GetMapping("/user")
    private ResponseEntity<HuanXinUserVo> queryHuanXinUser(){
        try {
            HuanXinUserVo huanXinUserVo = this.huanXinService.queryHuanXinUser();
            if (ObjectUtil.isNotEmpty(huanXinUserVo)){
                return ResponseEntity.ok(huanXinUserVo);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }

}
